function login() {
	$.post("php/ajax/login.php", {email:$('#email').val(), password:$('#password').val()}, function(data){
		if(data != false) {
			$('#reg').fadeOut('slow', function() {
				   $(this).remove();
			});
			
			$('#profile').fadeIn('slow');

			
			$('#rightbar').fadeIn('slow', function() {
				$('#rightbar').load('php/pages/sidebar.php');
			});
			
			
			$('#login_content').fadeOut('slow', function() {
				$('#login_content').fadeIn("slow");
				$('#login_content').html('Benvenuto, ' + data + '  [ <a href="#" onclick="logout()">logout</a> ]');
			});
			
		} else {
			$('#login_content').fadeOut('slow', function() {
				$('#login_content').fadeIn("slow");
				$('#login_content').html('Nome utente e/o password non corretti [ <a href="#" onclick="relogin()">riprova</a> ]');
				
			 });
			
		}
	})
}

function logout() {
	$.post("php/ajax/logout.php", {logout:"logout"}, function(data) {
		if(data != false) {
			$('#profile').fadeOut('slow', function() {
				   $(this).remove();
			});
			
			$('#reg').fadeIn('slow');
			
			$('#rightbar').fadeIn('slow', function() {
				$('#rightbar').load('php/pages/sidebar.php');
			});
			
			$('#login_content').fadeOut('slow', function() {
				$('#login_content').fadeIn("slow");
				$('#login_content').html('Logout effettuato correttamente [ <a href="#" onclick="relogin()">login</a> ]');
			});
		} else {
			$('#login_content').fadeOut('slow', function() {
				$('#login_content').fadeIn("slow");
				$('#login_content').html('Errore nel logout');
			});
		}
	})
}